<!-- 作者 : liandyao 公司: yidu -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>鲜花类型维护</title>
    <link rel="stylesheet" href="/res/layui/css/layui.css">
    <script src="/res/layui/layui.js"></script>
    <script src="/res/js/tools.js"></script>
</head>
<body>
<form class="layui-form" action="" lay-filter="example" id="myform">
    <input type="hidden" name="typeId">
    <div class="layui-form-item">
        <label class="layui-form-label">类型名字</label>
        <div class="layui-input-inline">
            <input type="text" name="typeName" required lay-verify="required" placeholder="请输入类型名字" autocomplete="off" class="layui-input">
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型备注</label>
        <div class="layui-input-inline">
            <input type="text" name="typeRemark"   placeholder="请输入类型备注" autocomplete="off" class="layui-input">
        </div>

    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="parent.layer.closeAll()">关闭</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        var $ = layui.$;





        //监听提交
        form.on('submit(formDemo)', function(data){
            //没有文件上传时提交表单的代码
            let url = "/flType/addOrUpdate";
            let data_= data.field;//需要提交的数据
            $.post(url,data_,function (resp) {
                if(resp.state==1){
                    //在子页面里面调用父页面的方法
                    parent.closeLayer(resp.msg);
                }else{
                    layer.msg(resp.msg);
                }
            },"json");
            return false;
        });

        //给表单赋值
        setFormValue();

        function setFormValue(){
            let flId = getQueryString("id");
            if(flId){ //flId==""  flId==null  flId==undefined
                let url_ = "/flType/selectOne";
                let data_ = {id:flId};
                $.get(url_,data_,function (resp) {
                    console.info(resp);
                    if(resp.state==1){
                        //给表单赋值
                        form.val('example', resp.data);
                    }
                },"json")
            }

        }

    });
</script>
</body>
</html>